<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后花园：CPCC</title>
</head>
<link rel="stylesheet" href="/static/css/layui.css">

<body>
<div class="layui-container" style="margin-top: 50px">
    <div class="layui-row">
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户账号</label>
                    <div class="layui-input-block">
                        <input type="text" name="user" id="user" value="{$user}" lay-verify="title" autocomplete="off" placeholder="请输入标题"
                               class="layui-input" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">新密码</label>
                    <div class="layui-input-block">
                        <input type="password" name="password" id="password" lay-verify="required" lay-reqtext="密码是必填项，岂能为空？"
                               placeholder="请输入密码" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">确认密码</label>
                    <div class="layui-input-block">
                        <input type="password" name="repassword" id="repassword" lay-verify="required" lay-reqtext="密码是必填项，岂能为空？"
                               placeholder="请输入密码" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn ok" lay-submit="" lay-filter="demo1">提交更改</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </div>
        <div class="layui-col-xs4 layui-col-sm12 layui-col-md4">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </div>
    </div>
</div>
</body>
<script src="/static/layui.js"></script>
<script src="/static/vendor/jquery/jquery-1.12.4.min.js"></script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        $('.ok').click(function () {
            var user = $('#user').val();
            var password = $('#password').val();
            var repassword = $('#repassword').val();
            if(repassword!=password){
                layer.msg('请确认两次密码是否相同',{icon:2});
                return false;
            }
            $.post('{:url("admin/updatepassword")}', {
                    'user': user,
                    'password': password
                }
                , function (res) {
                    if (res.code == 1) {
                        location.href=res.url;
                    } else {
                        layer.msg(res.msg,{icon: 2});
                    }
                }, 'json');
        })
    });
</script>
</html>